package com.liaow.test.elasticsearch.pojo;

import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
 * @Description: 测试商品 实体类
 * @Author: L.Wen
 * @Create_Time: 2020/09/25 17:36
 */
@AllArgsConstructor
@NoArgsConstructor
@ToString
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "测试商品 实体类", description = "测试商品 实体类")
@Data
@Document(indexName = "item", type = "docs", shards = 1, replicas = 0)  // 创建Elasticsearch索引映射
public class Item {

    @ApiModelProperty(value = "自增主键id")
    @Id
    private Long id;

    @ApiModelProperty(value = "标题")
    @Field(type = FieldType.Text, analyzer = "ik_max_word") // 使用ik分词器
    private String title;

    @ApiModelProperty(value = "分类")
    @Field(type = FieldType.Keyword)
    private String category;

    @ApiModelProperty(value = "品牌")
    @Field(type = FieldType.Keyword)
    private String brand;

    @ApiModelProperty(value = "价格")
    @Field(type = FieldType.Double)
    private Double price;

    @ApiModelProperty(value = "图片地址")
    @Field(type = FieldType.Keyword, index = false) // 不需要分词，不需要创建索引
    private String images;

}
